<?php
class AdZonePortlet extends RightSidePortlet{

	public $title="Announcements";
	public $zone=1;
	public $cycle=false;
	public $fx='fade';
	public $speed=1400;
	public $timeout=10000;
	public $width='auto';


	public function init()
	{
		parent::init();
		$file=Yii::app()->getAssetManager()->publish($this->getViewPath().DIRECTORY_SEPARATOR.'jquery.cycle.all.min.js');
		Yii::app()->clientScript->registerScriptFile($file);
	}


	protected function renderContent()
	{
		// Old oio app integration script
	//	echo "<script language=\"javascript\" src=\"http://www.melbournecoffeereview.com/wp-content/plugins/oiopub-direct/js.php?type=banner&zone={$this->zone}\"></script>";
	//	$params=array('fx'=>$this->fx,
	//		   'speed'=>   $this->speed, 
	//		    'timeout'=> $this->timeout);
	//	$options=CJavaScript::encode($params);
	//	$script="$('#oio-banner-{$this->zone}').cycle({$options});$('#oio-banner-{$this->zone}').css('width','{$this->width}');";
	//	Yii::app()->clientScript->registerScript($this->getId(), $script );
	
		echo <<<EOF
		<SCRIPT SRC="http://ads.jemmgroup.com/ttj?id=710374&cb=[CACHEBUSTER]&pubclick=[INSERT_CLICK_TAG]" TYPE="text/javascript"></SCRIPT>
EOF;
	}

	public function publish($filename){
		$assetFolder=$this->getViewPath().DIRECTORY_SEPARATOR.$this->theme;
		if(is_dir($assetFolder)){
			$assetFile=$assetFolder.DIRECTORY_SEPARATOR.$filename;
			return Yii::app()->getAssetManager()->publish($assetFile);
		}
	}
}